home *** CD-ROM | disk | FTP | other *** search
/ 10,000 Great Games / 10,000 Great Games.iso / Product / 66 / data1.cab / Source_Files / Src / Writeframe.cpp < prev   
C/C++ Source or Header  |  2000-01-16  |  2KB  |  111 lines

  1. #include "stdafx.h"
  2.  
  3. int view_backgroundarea = TRUE, view_gamearea = TRUE, low_detail_level = FALSE;
  4.  
  5. void write_frame()
  6. {    
  7.     // Check if this makes sense
  8.  
  9.     if (DD == 0)
  10.         return;
  11.  
  12.     // Update bitmaps in video memory
  13.     
  14.     cBMP::make_dynamic_use_of_video_mem();
  15.     
  16.     // write dirty parts of the screen
  17.     
  18.     if (no_parallax)
  19.     {
  20.         game_surface->do_scroll();        
  21.         game_surface->write_dirty();
  22.         game_surface->blit_to_backbuffer();        
  23.     }
  24.     else
  25.     {
  26.         // Write background surface
  27.  
  28.         if (!end_game || view_backgroundarea)
  29.         {
  30.             back_surface->do_scroll();
  31.             back_surface->write_dirty();
  32.             back_surface->blit_to_backbuffer();            
  33.         }
  34.         else
  35.         {
  36.             back_surface->clear_backbuffer();
  37.         }
  38.  
  39.         // Write game surface
  40.  
  41.         if (!end_game || view_gamearea)
  42.         {
  43.             game_surface->do_scroll();
  44.             game_surface->write_dirty();
  45.             game_surface->blit_to_backbuffer();            
  46.         }
  47.     }
  48.  
  49.     // Write left & right surfaces
  50.  
  51.     left_surface->do_scroll();
  52.     left_surface->write_dirty();
  53.     left_surface->blit_to_backbuffer();
  54.  
  55.     right_surface->do_scroll();
  56.     right_surface->write_dirty();
  57.     right_surface->blit_to_backbuffer();
  58.         
  59.     // Write info surface
  60.  
  61.     if (info_surface != 0 && (debug || end_game))
  62.     {
  63.         info_surface->clear(mask_color);
  64.  
  65.         lock_surface_for_primitives(info_surface);
  66.  
  67.         draw_grid();
  68.         write_debug_info();
  69.         cEditable::write_editables();
  70.  
  71.         unlock_surface_for_primitives();
  72.         
  73.         info_surface->blit_to_backbuffer();        
  74.     }
  75.  
  76.     // Write gravity effects
  77.  
  78.     write_gravity();
  79.  
  80.     // Make page visible
  81.  
  82.     if (inawin)
  83.     {        
  84.         // Create a clipper?
  85.  
  86.         if (clipper == 0)
  87.             init_directdraw_clipper();
  88.         
  89.         // Compute the position where to blit to
  90.  
  91.         CRect r(0, 0, SCREEN_X, SCREEN_Y);
  92.         gamewindow->ClientToScreen((LPPOINT)&r);
  93.         gamewindow->ClientToScreen((LPPOINT)&r + 1);        
  94.         r.left -= gamewindow->GetScrollPosition().x;
  95.         r.right -= gamewindow->GetScrollPosition().x;
  96.         
  97.         // Do the blit
  98.  
  99.         while (!draw_ok(screen->Blt(&r, backbuffer, 0, DDBLT_WAIT, 0)));
  100.     }
  101.     else
  102.     {        
  103.         // We're full screen, just flip
  104.  
  105.         while (!draw_ok(screen->Flip(0, DDFLIP_WAIT)));
  106.     }
  107.  
  108.     // All dirty rectangles have been processed
  109.  
  110.     cSurface::all_surfaces_not_dirty();
  111. }